home *** CD-ROM | disk | FTP | other *** search
/ Otherware / Otherware_1_SB_Development.iso / mac / developm / source / ncsat.cpt / Telnet2.5 final / main / netevent.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-06-12  |  16.8 KB  |  666 lines

  1. #ifdef lint
  2. static char *SCCSid = "%W%    (NCSA)    %G%";
  3. #endif
  4. /*
  5. *    netevent.c
  6. *     by Gaige B. Paulsen
  7. ****************************************************************************
  8. *    Part of NCSA Telnet for the Macintosh                                   *
  9. *                                                                          *
  10. *      Uses    :                                                               *
  11. *      TCP/IP kernel for NCSA Telnet                                       *
  12. *      by Tim Krauskopf                                                    *
  13. *       with Macintosh code by Gaige B. Paulsen                                 *
  14. *                                                                          *
  15. *      National Center for Supercomputing Applications                     *
  16. *      152 Computing Applications Building                                 *
  17. *      605 E. Springfield Ave.                                             *
  18. *      Champaign, IL  61820                                                *
  19. *                                                                          *
  20. *                                                                          *
  21. ****************************************************************************
  22. *
  23. *    Network event handler for NCSA Telnet for the Macintosh
  24. *
  25. *    Called by:
  26. *        event.c
  27. *        maclook.c
  28. */
  29.  
  30. /*
  31.  *    Files for inclusion.
  32.  */
  33. #include    <stdio.h>
  34. #include     <string.h>
  35.  
  36. #include    <Dialogs.h>
  37. #include    <Events.h>
  38. #include    <Memory.h>
  39. #include    <Windows.h>
  40. #include    <Menus.h>
  41.  
  42. #include    "hostform.h"
  43. #include    "whatami.h"
  44. #include    "wind.h"
  45. #include "configrec.h"
  46. #include "util.h"
  47. #include "bkgr.h"
  48. #include "maclook.h"
  49. #include "user.h"
  50. #include "menu.h"
  51. #include "tools.h"
  52.  
  53. #include "rsmac.h"
  54. #include "vrrgmac.h"
  55. #include "tekrgmac.h"
  56. #include    "vsdata.h"
  57. #include    "vskeys.h"
  58.  
  59. #include    "Prefs.h"
  60.  
  61. #define HFTP 21                /* BYU mod */
  62.  
  63. #define Conn        5
  64. #define COnext        1
  65. #define OopsDLOG    640
  66. #define PASTELEFT    130        /* UserEvent, PASTELEFT causes pasteText */
  67. #define PASTESIZE    32        /* BYU 2.4.7 - Paste in small chunks */
  68.  
  69. int
  70.     blocksize,        /* how large do we make the blocks when we read? */
  71.     ev,                /* Event type */
  72.     what,            /* What kind of net event */
  73.     dat;            /* The data for the event */
  74.  
  75. extern WindRec
  76.     *screens,                /* The screen array from Maclook */
  77.     ftplog;                    /* The FTP log screen from Maclook */
  78.  
  79. extern unsigned char 
  80.     tempspot[];                /* 256 bytes for temp strings */
  81.  
  82. unsigned char *readspace;    /* main buffer space */
  83.  
  84. extern void DoTheMenuChecks();
  85.  
  86. extern short slip_connection;    /* BYU 2.4.16 */
  87.  
  88. extern int
  89.     MacBinary,                /* MacBinary status from menu.c, for resetting if prefs say so.. */
  90.     ScrlLock,                /* Hey, do we have scroll lock? */
  91.     scrn,                    /* The current screen from Maclook */
  92.     numwindows;                /* The number of windows now from Maclook */
  93. extern void         /* BYU */
  94.     ftpgo(),        /* BYU */
  95.     ftppi(),        /* BYU */
  96.     userftpd();        /* BYU */
  97. char *errmsg,
  98.      *neterrstring();
  99. pascal int
  100.      modalProc();
  101. char ftpname[128];
  102. int portNo;
  103. long ftptime;
  104. #ifndef MPW
  105. long TickCount();
  106. #endif
  107. extern MenuHandle myMenus[];
  108.  
  109. int FileInTransit;
  110.  
  111. void NetError
  112.   (
  113.     int code
  114.   )
  115. {
  116.     char buffer1[100],buffer2[100], *neterrstring();
  117.     int ev,what,class;
  118.     short dItem;
  119.     DialogPtr dtemp;
  120.  
  121.     buffer1[0]=0;
  122.     buffer2[0]=0;
  123.  
  124.     if (code<0) {
  125.         strncpy( buffer2, neterrstring(code), 99);
  126.         ev = Sgetevent( ERRCLASS,&what,&code);
  127.         if (ev)
  128.             strncpy( buffer1, neterrstring(code), 99);
  129.         }
  130.     else
  131.         strncpy( buffer1, neterrstring(code), 99);
  132.  
  133.     class = code/100;
  134.     if ((class==1 || class==5 || class==9 ) && ( code!=103)) {
  135.         /* Ok, I'll show the user these */
  136. #ifndef MPW
  137.         paramtext( ctop(buffer1),ctop(buffer2),"\P ","\P ");
  138. #else
  139.         paramtext( buffer1,buffer2," "," ");
  140. #endif
  141.         dtemp=GetNewDialog(OopsDLOG,(Ptr) 0L,(WindowPtr) -1L);    /* Put up the error notice */
  142.         ModalDialog((ModalFilterProcPtr) modalProc,&dItem);        /* Get an event */
  143.         DisposDialog(dtemp);            /* Take it off.....all off......*/
  144.         }
  145.     else {
  146.         if (buffer1[0])
  147.             putln(buffer1);
  148.         if (buffer2[0])
  149.             putln(buffer2);
  150.         }
  151.  
  152. }
  153.  
  154. void RangeError
  155.   (
  156.     int i
  157.   )
  158. {
  159.     char temp[20];
  160.  
  161.     sprintf(temp,"%d in %d", -i,numwindows);
  162.     putln(temp);
  163. }
  164.  
  165. int WindByPort
  166.   (
  167.     int port
  168.   )
  169. {
  170.     int i=0;
  171.  
  172.     while (i<numwindows && (screens[i].port!=port || screens[i].active <0)) i++;
  173.  
  174.     if (i>=numwindows) {
  175.         i = 0;                                    /* BYU */
  176.         while ((i<numwindows) &&                 /* BYU */
  177.             ((screens[i].ftpport!=port) ||         /* BYU */
  178.             (screens[i].active <0))) i++;        /* BYU */
  179.         if (i>=numwindows) {                    /* BYU */
  180.             putln("Can't find a window for the port # in WindByPort");    /* BYU */
  181.             RangeError(i);            /* BYU */
  182.             if (i==0) i=999;        /* BYU */
  183.             return(-i);                /* BYU */
  184.             }                        /* BYU */
  185.         }                            /* BYU */
  186.  
  187.     return(i);
  188. }
  189.  
  190. int WindByDom
  191.   (
  192.     int port
  193.   )
  194. {
  195.     int i=0;
  196.  
  197.     while (i<numwindows && (screens[i].port!=port || screens[i].active >=0)) i++;
  198.  
  199.     if (i>=numwindows) {
  200.         if (i==0) i=999;
  201.         putln("CANT FIND THE domPORT SPECIFIED");
  202.         return(-i);
  203.         }
  204.  
  205.     return(i);
  206. }
  207.  
  208. void FlushNetwork
  209.   (
  210.     int scrn
  211.   )
  212. {
  213.     int throwsize,cnt=512;
  214.     
  215.     if (blocksize < 512)
  216.         throwsize = 512;
  217.     else
  218.         throwsize = blocksize;
  219.  
  220.     RSskip(screens[scrn].vs, 1);                /* Don't do any output */
  221.  
  222.     while (cnt>0) {
  223.         cnt = netread(dat,readspace,throwsize);
  224.         parse( &screens[scrn ], readspace, cnt);
  225.         }
  226.  
  227.     RSskip(screens[scrn].vs, 0);                /* Do output now */
  228.     SetPort( screens[scrn].wind);
  229.     InvalRect(&screens[scrn].wind->portRect);    /* Don't forget to redraw */
  230. }
  231.  
  232.  
  233. ftppasteText( scrn)        /* BYU */
  234. int scrn;                /* BYU */
  235. {                        /* BYU */
  236.     char *ascii;        /* BYU */
  237.                         /* BYU */
  238.     ascii = screens[scrn].outptr;                    /* BYU */
  239.     while ((screens[scrn].outlen > 0) &&             /* BYU */
  240.         (*ascii>31) && (*ascii <127)) {                /* BYU */
  241.         parse( &screens[ scrn], ascii, 1);            /* BYU */
  242.         screens[scrn].kbbuf[ screens[scrn].kblen++ ] = *ascii;    /* BYU */
  243.         screens[scrn].outlen--;                        /* BYU */
  244.         ascii++;                                    /* BYU */
  245.         }                                            /* BYU */
  246.     screens[scrn].outptr = ascii;                    /* BYU */
  247.     if (*ascii == '\015') {                            /* BYU */
  248.         parse( &screens[scrn],"\015\012",2);                    /* BYU */
  249.         screens[scrn].kbbuf[ screens[scrn].kblen++ ] = 0;        /* BYU */
  250.         ftppi(screens[scrn].kbbuf);                                /* BYU - ftp client */
  251.         screens[scrn].kblen=0;                                    /* BYU */
  252.         }                                    /* BYU */
  253.     while ((screens[scrn].outlen > 0) &&     /* BYU */
  254.         ((*ascii<=31) || (*ascii >=127))) {    /* BYU */
  255.         screens[scrn].outlen--;                /* BYU */
  256.         screens[scrn].outptr++;                /* BYU */
  257.         }                /* BYU */
  258. }                        /* BYU */
  259.  
  260.  
  261. void pasteText
  262.   (
  263.     int scrn
  264.   )
  265. {
  266.     int amount;
  267.     if (!screens[scrn].outlen)
  268.         return;
  269.  
  270. /* BYU 2.4.7 - Need to avoid the Macintosh sending more than the host 
  271.    can handle, so wait for two cycles (back to this routine) of no 
  272.    input from the host before each chunk of the paste buffer is sent.
  273. */
  274.     if ((screens[scrn].connectionType == 0) || slip_connection) {    /* BYU 2.4.16 */
  275.  
  276.         if (netpush(screens[scrn].port) != 0) {            /* BYU 2.4.16 - wait until not busy */
  277.             netputevent( USERCLASS, PASTELEFT, scrn);    /* BYU 2.4.16 */
  278.             return;                                        /* BYU 2.4.16 */
  279.         }                                                /* BYU 2.4.16 */
  280.         if (screens[scrn].incount) {                    /* BYU 2.4.16 */
  281.             screens[scrn].incount = 0;                    /* BYU 2.4.16 */
  282.             screens[scrn].outcount = 0;                    /* BYU 2.4.16 */
  283.             netputevent( USERCLASS, PASTELEFT, scrn);    /* BYU 2.4.16 */
  284.             return;                                        /* BYU 2.4.16 */
  285.         }                                                /* BYU 2.4.16 */
  286.         if (screens[scrn].outcount < 2) {                /* BYU 2.4.16 */
  287.             screens[scrn].outcount++;                    /* BYU 2.4.16 */
  288.             netputevent( USERCLASS, PASTELEFT, scrn);    /* BYU 2.4.16 */
  289.             return;                                        /* BYU 2.4.16 */
  290.         }
  291.         if (netqlen(screens[scrn].port) > 0) {            /* BYU 2.4.16 - wait until not full */
  292.             netputevent( USERCLASS, PASTELEFT, scrn);    /* BYU 2.4.16 */
  293.             return;                                        /* BYU 2.4.16 */
  294.         }                                                /* BYU 2.4.16 */
  295.  
  296.     }                                                /* BYU 2.4.16 */
  297.  
  298.     if (screens[scrn].ftpstate != 0)                 /* BYU */
  299.         ftppasteText( scrn);                        /* BYU */
  300.     else {                                            /* BYU */
  301. #if 0    /* BYU - VAX/VMS systems can't handle large pastes at the time of this patch. */
  302.         amount = netwrite(  screens[scrn].port,        /* BYU */
  303.                             screens[scrn].outptr,    /* BYU */
  304.                             screens[scrn].outlen);    /* BYU */
  305. #else                                                /* BYU */
  306.         if (PASTESIZE <= screens[scrn].outlen)        /* BYU */
  307.             amount = PASTESIZE;                        /* BYU */
  308.         else                                        /* BYU */
  309.             amount = screens[scrn].outlen;            /* BYU */
  310.         amount = netwrite(  screens[scrn].port,        /* BYU */
  311.                             screens[scrn].outptr,    /* BYU */
  312.                             amount);                /* BYU */
  313. #endif                                                /* BYU */
  314.         if (screens[scrn].echo)                                        /* BYU */
  315.             parse( &screens[scrn], screens[scrn].outptr,amount);    /* BYU */
  316.         screens[scrn].outlen -= amount;                                /* BYU */
  317.         screens[scrn].outptr += (long) amount;                        /* BYU */
  318.         }                                                            /* BYU */
  319.  
  320.     if ( screens[scrn].outlen <=0) {
  321.         screens[scrn].clientflags &= ~PASTE_IN_PROGRESS;    /* BYU 2.4.7 */
  322.         HUnlock(screens[scrn].outhand);
  323.         DisposHandle(screens[scrn].outhand);
  324.         (char *) screens[scrn].outhand = screens[scrn].outptr = (char *) 0L;
  325.         }
  326.     else
  327.         netputevent( USERCLASS, PASTELEFT, scrn);
  328. }
  329.  
  330.  
  331.  
  332.  
  333.  
  334.  
  335.  
  336.  
  337.  
  338.  
  339.  
  340. void DoNetEvents
  341.   (
  342.     void
  343.   )
  344.   {
  345.     int i,cnt;
  346.     
  347.     ev = Sgetevent(USERCLASS | CONCLASS | ERRCLASS,&what,&dat);
  348.  
  349.     if ( !ev ) {
  350.         if ( (ftptime < TickCount()) && FileInTransit) {
  351.             long pos;
  352.  
  353.             Sftpstat(&pos);                    /* get transfer status */
  354.             if (pos <= 0) 
  355.                 ftpmess("FTP Status: transferring\015\012");
  356.             else {
  357.                 if (FileInTransit+2)
  358.                     sprintf(tempspot,"FTP Status: %ld bytes remaining.\015\012", pos);
  359.                 else
  360.                     sprintf(tempspot,"FTP Status: %ld bytes transferred.\015\012", pos);
  361.  
  362.                 ftpmess(tempspot);
  363.                 }
  364.  
  365.             ftptime=TickCount()+30;            /* 1/2 second intervals */
  366.             }
  367.         return;
  368.         }
  369.  
  370.     switch( what) {
  371.     case ERRCLASS:                            /* Error event */
  372.             NetError(dat);
  373.         break;
  374.  
  375.     case CONCLASS:                            /* Connection type event */
  376.             switch (ev) {
  377.                 case CONOPEN:                /* connection opened or closed */
  378. #ifdef JOHN_DEERE
  379.                 {     extern    int jdp;
  380.                     if (jdp == dat) {
  381.                         netwrite( jdp, "Hello from Macintosh\015\012",22);    /* BYU 2.4.18 - changed \n to \015 */
  382.                         netclose( jdp);
  383.                         jdp = netlisten( 2001,0);        /* BYU 2.4.15 */
  384.                         }
  385.                 }
  386. #endif
  387.                     i=WindByPort(dat);
  388.                     if (i<0) { RangeError(i); return; }
  389. /* BYU mod - This tests TRUE if it is the telnet port or the main ftp port */
  390.                     if (dat == screens[i].port) {        /* BYU - is this Telnet? */
  391.                         screens[ i].active=0;            /* BYU - Mark active */
  392.                         RSshow( screens[i].vs);            /* BYU */
  393.                         SelectWindow(screens[i].wind);    /* BYU */
  394. #if 1                                                    /* BYU 2.4.20 */
  395.                         if (screens[i].ftpstate != 0)     /* BYU 2.4.20 - Only if not FTP */
  396.                             userftpd(CONOPEN,dat);        /* BYU */
  397. #else                                                    /* BYU 2.4.20 */
  398.                         if (screens[i].ftpstate == 0) {    /* BYU - Only if not FTP */
  399.                             netpush(screens[i].port);    /* BYU */
  400.                             netwrite(screens[i].port,"\377\375\001\377\375\003\377\374\43",9); /* BYU - Default telnet parms */
  401.                         } else {                        /* BYU */
  402.                             userftpd(CONOPEN,dat);        /* BYU */
  403.  
  404.                         }                                /* BYU */
  405. #endif                                                    /* BYU 2.4.20 */
  406.                         screens[i].Usga=1;        /* BYU */
  407.                         changeport(scrn,i);        /* BYU */
  408.                         liveport(scrn);            /* BYU */
  409.                         DoTheMenuChecks();        /* BYU */
  410.                     } else {                    /* BYU - not Telnet so must be FTP */
  411.                       userftpd(CONOPEN,dat);    /* BYU */
  412.                     }                            /* BYU */
  413.                     break;
  414.  
  415.                 case CONDATA:                /* data arrived for me */
  416.                     i=WindByPort(dat);                                    /* BYU */
  417.                     if (i<0) { RangeError(i); return; }                    /* BYU */
  418.                     if (ScrlLock || !screens[ WindByPort(dat)].enabled)
  419.                         netputuev( CONCLASS, CONDATA, dat);
  420.                     else {
  421.                         if (screens[i].ftpstate == 0) {                        /* BYU */
  422.                             cnt = netread(dat,readspace,blocksize);            /* BYU */
  423.                             parse( &screens[ WindByPort( dat)], readspace, cnt);    /* BYU */
  424.                             screens[i].incount += cnt;                /* BYU 2.4.7 */
  425.                             }                            /* BYU */
  426.                         else {                            /* BYU */
  427.                             userftpd(CONDATA,dat);        /* BYU */
  428.                             }                            /* BYU */
  429.                         }
  430.                     break;
  431.  
  432.                 case CONFAIL:
  433.                     {
  434.                         int i;
  435.                         netclose( dat);
  436.                         i= WindByPort(dat);
  437.                         if (i<0) { RangeError(i); return; }
  438. #ifndef MPW
  439.                         OtherError( "\PHost or gateway not responding:",
  440.                                     screens[i].machine);
  441. #else
  442.                         OtherError( "Host or gateway not responding:",
  443.                                     screens[i].machine);
  444. #endif MPW
  445.                         destroyport( i);
  446.                     }
  447.                     break;
  448.  
  449.                 case CONCLOSE:
  450.                     {
  451.                         int i;
  452.  
  453.                         i= WindByPort(dat);
  454.                         if (i<0) { 
  455.                             netclose( dat);            /* We close again.... */
  456.                             RangeError(i);
  457.                             return;
  458.                             }
  459. /* BYU - This tests TRUE if it is the telnet port or the main ftp port */
  460.                         if (dat == screens[i].port) {        /* BYU */
  461.                             putln("Closing....");            /* BYU */
  462.                             FlushNetwork(i);                /* BYU */
  463.                             netclose( screens[i].port);        /* BYU */
  464.                             removeport(i);                    /* BYU */
  465.                             }                                /* BYU */
  466.                         else {                                /* BYU */
  467.                             userftpd(CONCLOSE,dat);            /* BYU */
  468.                             }                                /* BYU */
  469.                     }
  470.                     break;
  471.  
  472.                 default:
  473.                     break;
  474.                 }
  475.         break;
  476.  
  477.     case USERCLASS:
  478.             switch (ev) {
  479.                 case DOMOK:                                            /* domain worked */
  480.                     {
  481.                         struct machinfo *mp;
  482.                         int i;
  483.                         
  484.                         i  = WindByDom( dat);
  485.                         if (i<0) { RangeError(i); return; }
  486.                         mp = Slooknum( dat);                        /* get machine info */
  487.                         if (screens[i].ftpstate != 0)                     /* BYU - ftp client */
  488.                             screens[ i].port  = Snetopen(mp,HFTP,0);    /* BYU 2.4.15 - open to host name */
  489.                         else                                             /* BYU */
  490.                             screens[ i].port  = Snetopen(mp,mp->port,0);/* BYU 2.4.15 - open to host name */
  491.                         if (screens[i].port <0) {                    /* Handle Snetopen fail */
  492.                             destroyport( i);
  493.                             }
  494.                         screens[i].active = 1;                        /* Change real status */
  495.                         opnport( i);                                /* Change status mark */
  496.                     }
  497.                     break;
  498.                 case DOMFAIL:    /* domain failed */
  499.                     {
  500.                         i= WindByDom(dat);
  501.                         if (i<0) { RangeError(i); return; }
  502. #ifndef MPW
  503.                         OtherError( "\PHost not in hosts file or on server:",
  504.                                     screens[i].machine);
  505. #else
  506.                         OtherError( "Host not in hosts file or on server:",
  507.                                     screens[i].machine);
  508. #endif MPW
  509.                         destroyport( i);
  510.                     }
  511.                     break;
  512.                 case FTPBEGIN:
  513.                     Sftpname(ftpname);            /* get name */
  514. /*                    ftpmess("\015\012FTP transferring: "); */
  515. /*                    ftpmess(ftpname); */
  516. /*                    ftpmess("\015\012"); */
  517.                     FileInTransit=dat;
  518.                     ftptime=TickCount();
  519.                     break;
  520.                 case FTPLIST:
  521.                     ftpmess("FTP Directory being Sent\015\012");
  522.                     break;
  523.                 case FTPEND:
  524.                     
  525.             /*        if (!(FileInTransit+2))        
  526.                         ftpmess("\015\012");       */
  527.                     ftpmess("FTP Transfer Concluding\015\012");
  528.                     ftpmess("\015\012");
  529.                     FileInTransit=0;
  530.                     break;
  531.                 case FTPCOPEN:
  532.                     {
  533.                         struct machinfo *mp;
  534.                         unsigned char ftpinfo[8];
  535.                         
  536.                         if (Prefs.MacBReset) 
  537.                             MacBinary = Prefs.MacBinary;
  538.                         updateMenuChecks();
  539.                         xferstart();
  540.                         ftpmess("-----------------------------------------------------------------------------\015\012");
  541.                         ftpmess("FTP server initiated from host: ");
  542.                         Sftphost(ftpinfo);
  543.  
  544.                         if ((NULL == (mp = Slookip(ftpinfo))) || (NULL == mp->sname)) 
  545.                             sprintf(&tempspot[4],"%d.%d.%d.%d\015\012",
  546.                                     (int)ftpinfo[0],(int)ftpinfo[1],
  547.                                     (int)ftpinfo[2],(int)ftpinfo[3]);
  548.                         else
  549.                             sprintf(&tempspot[4],"%s\015\012",mp->sname);
  550.                         ftpmess(&tempspot[4]);
  551.                     }
  552.                     break;
  553.                 case FTPCLOSE:
  554.                     xferdone();
  555.                     if (Prefs.MacBReset) 
  556.                         MacBinary = Prefs.MacBinary;
  557.                     updateMenuChecks();
  558.                     ftpmess("FTP server ending session\015\012");
  559.                     ftpmess("-----------------------------------------------------------------------------\015\012");
  560.                     ftpmess("\015\012");
  561.  
  562.                     break;
  563.  
  564.     
  565.                 case FTPUSER:
  566.                     ftpmess("FTP user ");
  567.                     Sftpuser(tempspot);
  568.                     ftpmess(tempspot);
  569.                     ftpmess(" logging in\015\012");
  570.                     break;
  571.                     
  572.                 case FTPPWOK:
  573.                     ftpmess("FTP password OK - logged in\015\012");
  574.                     break;
  575.                 case FTPPWNO:
  576.                     ftpmess("FTP password failed - access denied\015\012");
  577.                     break;
  578.  
  579.                 case 128:            /* RGredraw event */
  580.                     if (VGalive(dat) && RGsupdate(dat))
  581.                         TekEnable(dat);
  582.                     break;
  583.                 case PASTELEFT:
  584.                     pasteText(dat);
  585.                     break;
  586.                 default:
  587.                     break;
  588.             }
  589.         break;
  590.     default:
  591.         break;
  592.         }
  593.   } /* DoNetEvents */
  594.  
  595. void OtherError
  596.   (
  597.     char *mess1,
  598.     char *mess2
  599.   )
  600. {
  601.     char buffer1[100],buffer2[100];
  602.     short dItem;
  603.     DialogPtr dtemp;
  604.  
  605.     buffer1[0]=0;
  606.     buffer2[0]=0;
  607.  
  608.     strncpy(buffer1, mess1, 99);
  609.     strncpy(buffer2, mess2, 99);
  610.  
  611. #ifndef MPW
  612.     paramtext( buffer1,buffer2,"\P ","\P ");
  613. #else
  614.     paramtext( buffer1,buffer2,"P ","P ");
  615. #endif MPW
  616.  
  617.     dtemp=GetNewDialog(OopsDLOG,(Ptr) 0L,(WindowPtr) -1L);    /* Put up the error notice */
  618.     ModalDialog((ModalFilterProcPtr) modalProc,&dItem);        /* Get an event */
  619.     DisposDialog(dtemp);            /* Take it off.....all off......*/
  620. }
  621.  
  622. void ShowAllErrors
  623.   (
  624.     void
  625.   )
  626.   {
  627.     int ev=1, what, dat;
  628.  
  629.     while (ev)
  630.       {
  631.         ev = Sgetevent( ERRCLASS,&what,&dat);
  632.         if (ev)
  633.             NetError(dat);
  634.       }
  635.   }
  636.  
  637. /*****************************************************************************/
  638. /*  setblocksize()
  639. *  Make sure that we have space for the block of data that is to be read each
  640. *  time the netread() is called.
  641. */
  642. int setblocksize
  643.   (
  644.     int tosize
  645.   )
  646. {
  647.  
  648.     blocksize = tosize;                            /* keep size of block */
  649.     
  650.     if (tosize < 512)                            /* minimum buffer */
  651.         tosize = 512;
  652.  
  653.     if (readspace)
  654.         DisposPtr(readspace);                        /* free old block */
  655.         
  656.     if (NULL == (readspace = NewPtr(tosize + 100)))
  657.         return(-1);
  658.  
  659.     return(0);
  660. }
  661.  
  662.  
  663.  
  664.  
  665.  
  666.